<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateSystemEmail extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('system_email', array('engine' => 'MyISAM', 'comment' => '系统邮件'));
        $table
            ->addColumn('title', 'string', array('limit' => 120, 'null' => true, 'comment' => '主题'))
            ->addColumn('sender_from', 'string', array('limit' => 120,'null' => true, 'comment' => '来自'))
            ->addColumn('sender_to', 'string', array('limit' => 120,'null' => true, 'comment' => '发送到'))
            ->addColumn('email_type', 'string', array('limit' => 120,'null' => true, 'comment' => '邮件分类'))
            ->addColumn('email_tag', 'string', array('limit' => 120, 'null' => true, 'comment' => '邮件标签'))
            ->addColumn('content', 'text', array('null' => true, 'comment' => '邮件内容'))
            ->addColumn('folder', 'string', array('limit' => 120,'null' => true, 'comment' => '所属文件夹'))
            ->addColumn('appendix', 'string', array('limit' => 200,'null' => true, 'comment' => '邮件附件'))
            ->addColumn('is_read', 'string', array('limit' => 120,'null' => true, 'comment' => '是否读取'))
            ->addColumn('sending_time', 'string', array('limit' => 120,'null' => true, 'comment' => '发送时间'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();
    }
}
